import React, { Component } from 'react';
import {
    View,
    SafeAreaView,
    StatusBar
} from 'react-native';

import Color from "../utils/Color";

// import {useDarkModeContext} from 'react-native-dark-mode'
import {AppearanceProvider, Appearance} from 'react-native-appearance'

/**
 * 基类封装
 */


const backgroundColor = Appearance.getColorScheme() === 'dark' ? Color.darkBg : Color.lightBg

export default class BaseComponent extends Component {
    constructor(props) {
        super(props);
    }
    containerStyle = {flex: 1, backgroundColor: backgroundColor}

    hasSafeAreaView = false

    componentDidMount() {
        try {
            console.log(this.containerStyle, '测试主题')
            this.initData();
        } catch (error) {
            LOG('netlog-', error)
        }
    }

    /**
     * 初始化数据
     */
    initData() {

    }


    /**
     * 头部
     * @private
     */
    _renderHeader() {
    }

    /**
     * 渲染组件
     */
    _renderComponents() {
        return null;
    }

    render() {
        let Rootview = this.hasSafeAreaView ? SafeAreaView : View
        return (
            <AppearanceProvider>
                <Rootview style={this.containerStyle}>
                    <StatusBar
                        backgroundColor="#000"
                        barStyle="default"
                    />
                    {this._renderHeader()}
                    <View style={{flex: 1}}>
                        {/*{this._renderLoadStateComponents()}*/}
                        {this._renderComponents()}
                        {/*{this._renderOther2()}*/}
                    </View>
                </Rootview>
            </AppearanceProvider>

        )
    }

}
